//
//  TMHomeSubVCCell.m
//  TMBD Movie App
//
//  Created by zhangkai on 2023/4/2.
//

#import "TMHomeSubVCCell.h"
#import <Masonry.h>
@interface TMHomeSubVCCell()
@property(strong,nonatomic)UIImageView *cellIcon;
@property(strong,nonatomic)UIImageView *xingIcon;
@property(strong,nonatomic)UILabel *xingLabel;
@property(strong,nonatomic)UILabel *cellName;
@property(strong,nonatomic)UIView *bgView;
@end
@implementation TMHomeSubVCCell
- (void)configMvieInfoUI:(NSDictionary *)dict;{
    
    self.bgView.hidden = YES;
    self.xingIcon.hidden = YES;
    self.xingLabel.hidden = YES;
    
    [self.cellIcon sd_setImageWithURL:[NSURL URLWithString:[dict objectForKey:@"cover"]]];
    self.cellName.text = [dict objectForKey:@"title"];
    [self.cellName mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.xingIcon.mas_centerY);
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.right.equalTo(self.contentView.mas_right);
    }];
    
}
- (void)configUI:(NSDictionary *)dict;{
    
    [self.cellIcon sd_setImageWithURL:[NSURL URLWithString:[dict objectForKey:@"cover"]]];
    self.cellName.text = [dict objectForKey:@"title"];
    self.xingLabel.text = [dict objectForKey:@"rate"];

}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        self.cellIcon = [UIImageView new];
        self.cellIcon.contentMode = UIViewContentModeScaleAspectFill;
        self.cellIcon.clipsToBounds = YES;
        self.cellIcon.image = [UIImage imageNamed:@"karayipkorsanlar"];
        [self.contentView addSubview:self.cellIcon];
        [self.cellIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView);
            make.left.equalTo(self.contentView);
            make.right.equalTo(self.contentView);
            make.height.mas_equalTo(200);
        }];
        self.cellIcon.layer.cornerRadius = 16;
        
        
        UIView *bgView = [UIView new];
        bgView.backgroundColor = [UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:0.1000];
        [self.contentView addSubview:bgView];
        self.bgView = bgView;
        
        
        self.xingIcon = [UIImageView new];
        self.xingIcon.image = [UIImage imageNamed:@"shoucang"];
        [self.contentView addSubview:self.xingIcon];
        [self.xingIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.cellIcon.mas_bottom).offset(15);
            make.left.equalTo(self.contentView.mas_left).offset(18);
            make.height.width.mas_equalTo(15);
        }];
        
        self.xingLabel = [UILabel new];
        self.xingLabel.text = @"9.6";
        self.xingLabel.font = [UIFont systemFontOfSize:12];
        self.xingLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.xingLabel];
        [self.xingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.xingIcon.mas_centerY);
            make.left.equalTo(self.xingIcon.mas_right).offset(2);
        }];
        
        
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(22);
            make.centerY.equalTo(self.xingIcon);
            make.left.equalTo(self.xingIcon.mas_left).offset(-3);
            make.right.equalTo(self.xingLabel.mas_right).offset(3);
        }];
        bgView.layer.cornerRadius = 4;
        bgView.layer.masksToBounds = YES;
        
        self.cellName = [UILabel new];
        self.cellName.numberOfLines = 2;
        self.cellName.text = @"至死不渝";
        self.cellName.font = [UIFont systemFontOfSize:16];
        self.cellName.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.cellName];
        [self.cellName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.xingIcon.mas_centerY);
            make.left.equalTo(bgView.mas_right).offset(15);
            make.right.equalTo(self.contentView.mas_right);

        }];
        
        
    }
    return self;
}
@end
